package com.unknowpupil.design.observer2;

import com.unknowpupil.design.observer.Subject;

import java.util.Observable;
import java.util.Observer;

/**
 * @Description: <p>
 *  目标对象
 * </p>
 * @Author: <a> w10g </a>
 * @CreateDate: Create in 2020/4/28 16:29
 * @Classname: ConcreteSubject
 * @Version: 1.0
 */
public class ConcreteSubject extends Observable {
    private int state;
    public void set(int s){
         //目标状态发生了改变
        state = s;
        //便是目标对象已更改
        setChanged();
        //通知所有观察者
        notifyObservers(state);
    }

    public int getState() {
        return state;
    }

    public void setState(int state) {
        this.state = state;
    }
}
